%%
clear;
clc;
%数据预处理
x=linspace(0,1,50); % 设置x轴范围
y=x;
[X,Y]=meshgrid(x,y);
Z=(X).^2-sqrt((X).^2 + (Y-1).^2); 


% 设置坐标值相关参数
FontS=16;
FontW='bold';
az=50;el=20;
Lenght=20;Width=15;
Start_x=6;Start_y=6;

figure(1)
% 获取曲面对象
Fig=mesh(X,Y,Z);
colormap winter;
colorbar;

% 图像设置
view([az,el])  % 设置观察角度
axis([min(x) max(x) ...
    min(y) max(y) ...
    min(Z) max(Z)])  % 设置坐标轴范围
set(gcf,'Units', 'centimeters', 'Position',[Start_x Start_y Lenght Width]) % 设置图片大小

% 设置坐标轴标签
L(1) = xlabel('$x$','interpreter','latex','FontSize',FontS,'FontWeight',FontW);
L(2) = ylabel('$y$','interpreter','latex','FontSize',FontS,'FontWeight',FontW);
L(3) = zlabel('$z$','interpreter','latex','FontSize',FontS,'FontWeight',FontW);
L(4) = title('$z = 1-\sqrt{x^{2}+(y-1)^{2}}$','interpreter','latex','FontSize',FontS,'FontWeight',FontW);



%%
clc;
clear;
x1 = -500:10:500;
x2  = -500:10:500;
[x,y] = meshgrid(x1,x2);
m
z = -(x.*sin(sqrt(abs(x)))+y.*sin(sqrt(abs(y))));
xx=1000*rand(30,1)-500;
yy=1000*rand(30,1)-500;
zz = -(xx.*sin(sqrt(abs(xx)))+yy.*sin(sqrt(abs(yy))));
[nx,ny] = min(z);
[mx,my] = min(nx);
figure
subplot(1,2,1)
surf(x,y,z)
hold on
plot3(xx,yy,zz,'k*')%,'MarkerFaceColor','r'
shading interp
xlabel('x')
ylabel('y')
zlabel('f')
colormap(jet)
view([-152 43])
set(gca,'fontsize',12)
subplot(1,2,2)
surf(x,y,z)
hold on
plot3(x(ny(1),my),y(ny(1),my),mx,'ro','MarkerFaceColor','r','MarkerSize',10)%,'MarkerFaceColor','r'
shading interp
xlabel('x')
ylabel('y')
zlabel('f')
view([-152 43])
colormap(jet)
set(gca,'fontsize',12)

%%
clc;
clear;
x1 = -500:10:500;
x2  = -500:10:500;
[x,y] = meshgrid(x1,x2);

z=0.5 + ( (cos(sin(abs(x.^2-y.^2)))) -0.5 )/(1 + 0.001 * (x.^2+y.^2).^2 );
surf(x,y,z)

%%

